From: Giovanni Campagna Date: Sat, 2 Jun 2012 22:10:23 +0000 (+0200) Subject: Screen Shield: animate manual locking X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~6281 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=0e4171a87ca7926acc2e5c9f5a80a13ce71697ee;p=gnome-shell.git Screen Shield: animate manual locking When the screen shield is activated from the user menu, animate it instead of showing it abruptly. Also, ensure that the animation had time to finish before calling UPower to suspend, to avoid showing it when resuming. https://bugzilla.gnome.org/show_bug.cgi?id=619955 --- diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index 7a8bd3434..fcc079d03 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -24,6 +24,12 @@ const ARROW_DRAG_TRESHOLD = 0.4; const SUMMARY_ICON_SIZE = 48; +// Lightbox fading times +// STANDARD_FADE_TIME is used when the session goes idle, while +// SHORT_FADE_TIME is used when requesting lock explicitly from the user menu +const STANDARD_FADE_TIME = 10; +const SHORT_FADE_TIME = 2; + const Clock = new Lang.Class({ Name: 'ScreenShieldClock', @@ -318,7 +324,9 @@ const ScreenShield = new Lang.Class({ this._hasLockScreen = false; this._lightbox = new Lightbox.Lightbox(Main.uiGroup, - { inhibitEvents: true, fadeInTime: 10, fadeFactor: 1 }); + { inhibitEvents: true, + fadeInTime: STANDARD_FADE_TIME, + fadeFactor: 1 }); }, _onLockScreenKeyRelease: function(actor, event) { @@ -390,7 +398,7 @@ const ScreenShield = new Lang.Class({ let shouldLock = lightboxWasShown && this._settings.get_boolean(LOCK_ENABLED_KEY); if (shouldLock || this._isLocked) { - this.lock(); + this.lock(false); } else if (this._isModal) { this.unlock(); } @@ -398,7 +406,7 @@ const ScreenShield = new Lang.Class({ }, showDialog: function() { - this.lock(); + this.lock(true); this._showUnlockDialog(false); }, @@ -452,7 +460,7 @@ const ScreenShield = new Lang.Class({ this._dialog.destroy(); this._dialog = null; - this._resetLockScreen(); + this._resetLockScreen(false); }, _onUnlockSucceded: function() { @@ -464,7 +472,23 @@ const ScreenShield = new Lang.Class({ this._lockScreenGroup.hide(); }, - _resetLockScreen: function() { + _resetLockScreen: function(animate) { + if (animate) { + this.actor.opacity = 0; + Tweener.removeTweens(this.actor); + Tweener.addTween(this.actor, + { opacity: 255, + time: SHORT_FADE_TIME, + transition: 'easeOutQuad', + onComplete: function() { + this.emit('lock-screen-shown'); + }, + onCompleteScope: this + }); + } else { + this.emit('lock-screen-shown'); + } + this._lockScreenGroup.fixed_position_set = false; this._lockScreenGroup.show(); this._arrow.show(); @@ -542,7 +566,7 @@ const ScreenShield = new Lang.Class({ this.emit('lock-status-changed', false); }, - lock: function() { + lock: function(animate) { if (!this._hasLockScreen) this._prepareLockScreen(); @@ -553,7 +577,7 @@ const ScreenShield = new Lang.Class({ this._isLocked = true; this.actor.show(); - this._resetLockScreen(); + this._resetLockScreen(animate); this.emit('lock-status-changed', true); }, diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js index ed6f9f79f..7f8d544de 100644 --- a/js/ui/userMenu.js +++ b/js/ui/userMenu.js @@ -767,12 +767,12 @@ const UserMenuButton = new Lang.Class({ _onLockScreenActivate: function() { Main.overview.hide(); - Main.screenShield.lock(); + Main.screenShield.lock(true); }, _onLoginScreenActivate: function() { Main.overview.hide(); - Main.screenShield.lock(); + Main.screenShield.lock(false); this._userManager.goto_login_session(); }, @@ -795,8 +795,13 @@ const UserMenuButton = new Lang.Class({ this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) { this._session.ShutdownRemote(); } else { - Main.screenShield.lock(); - this._upClient.suspend_sync(null); + let tmpId = Main.screenShield.connect('lock-screen-shown', Lang.bind(this, function() { + Main.screenShield.disconnect(tmpId); + + this._upClient.suspend_sync(null); + })); + + Main.screenShield.lock(true); } } });